package com.yupi.generator;

import freemarker.template.TemplateException;
import com.yupi.generator.file.DynamicGenerator;
import com.yupi.generator.file.StaticGenerator;
import java.io.File;
import java.io.IOException;
import com.yupi.model.DataModel;

/**
 * @version 1.0
 * @Author yupi
 * @Date 2023-11-22
 * @注释 动静结合
 */
public class MainGenerator {


    public static void doGenerate(DataModel model) throws IOException, TemplateException {
        String inputRootPath = ".source/acm-template-pro";
        String outputRootPath="generated";

        String inputPath;
        String outputPath;
    //有分组
        boolean needGit=model.needGit;

    //有分组
        boolean loop=model.loop;

    //有分组
        String author=model.mainTemplate.author;
        String outputText=model.mainTemplate.outputText;

         inputPath=new File(inputRootPath,"src/com/yupi/acm/MainTemplate.java.ftl").getAbsolutePath();
         outputPath=new File(outputRootPath,"src/com/yupi/acm/MainTemplate.java").getAbsolutePath();
         DynamicGenerator.doGenerate(inputPath,outputPath,model);


        if(needGit){
              inputPath=new File(inputRootPath,".gitignore").getAbsolutePath();
              outputPath=new File(outputRootPath,".gitignore").getAbsolutePath();
              DynamicGenerator.doGenerate(inputPath,outputPath,model);
              inputPath=new File(inputRootPath,"README.md").getAbsolutePath();
              outputPath=new File(outputRootPath,"README.md").getAbsolutePath();
              DynamicGenerator.doGenerate(inputPath,outputPath,model);

        }



    }

}
